<template>
	<div class="login">
		<div class="login-top">
			<img src="../../assets/img/login-01.png" >
			<p>手机号注册/登录</p>
		</div>
		<div class="login-inp">
			<p><input type="phone" v-model.trim.lazy="phone" placeholder="请输入手机号" /></p>
			<p class="inp-txt"><input type="text" v-model.trim.lazy="Rand" placeholder="请输入验证码" /> <button @click="rand()">获取验证码</button></p>
			<p  class="inp-user"><button :class="{'button_default':show}" type="button" @click="setCookie()">一键注册/登录</button></p>
			<p><label>非大陆手机号登录</label><label>账号密码登录</label></p>
		</div>
		<div class="login-bottom">
			<div class="bottom-img">
				<img src="../../assets/img/login-wechar.png" >
				<img src="../../assets/img/login-qq.png" >
			</div>
			<p><input type="checkbox" v-model="show" />未注册游侠客账号的手机，登录时将同时注册，登录代表您已同意<button type="button">《服务协议》</button>和<button type="button">《隐私政策》</button></p>
		</div>
	</div>
</template>

<script>
	var ran = null;
	import Cookies from 'js-cookie';
	export default {
		name:'Login',
		data() {
			return{
				phone:'13564522456',
				Rand:'',
				show:false
			}
		},
		methods:{
			rand(){
				let res = /1[1|3|4|5|7|8|9][0-9][0-9]{8}$/g
				if(res.test(this.phone)&&this.phone){
					ran = Math.floor(Math.random()*10000)
					this.Rand = ran
				}
			},
			setCookie(){
				let res = /1[1|3|4|5|7|8|9][0-9][0-9]{8}$/g
				if(res.test(this.phone)&&this.phone){
					Cookies.set('phone',this.phone)
				}
				if(this.Rand==ran&&this.phone==Cookies.get('phone')&&this.show){
					let url = this.$route.query.url
					this.$router.push({path:url})
					this.$store.commit('setshow')
				}
			}
		},
	}
</script>

<style scoped>
.login{
	width: 100%;
	overflow: hidden;
}
.login-top{
	margin-top: 0.2rem;
	width: 100%;
	overflow: hidden;
	text-align: center;
}
.login-top img{
	width: 2.2rem;
	height: 2.2rem;
}
.login-top p{
	font-size: 0.45rem;
	font-weight: bold;
}
.login-inp{
	width: 100%;
	overflow: hidden;
	margin-top: 0.5rem;
	line-height: 1.6rem;
	margin-bottom: 3.7rem;
}
.login-inp p input{
	height: 0.8rem;
	outline: none;
	width: 100%;
	border: none;
	text-indent: 2em;
}
.login-inp .inp-txt input{
	width: 65%;
}
.login-inp .inp-txt button{
	border: none;
	background-color: white;
	color: #E6C81A;
	width: 25%;
	text-align: center;
	margin-left: 0.3rem;
}
.login-inp .inp-user{
	width: 85%;
	margin: 0 auto;
}
.login-inp .inp-user button{
	font-size: 0.45rem;
	border-radius: 0.2rem;
	width: 100%;
	border: none;
	line-height: 1.2rem;
	background: rgba(0,0,0,0.3);
	color: #161616;
}
.button_default{
	background: linear-gradient(135deg, #ffed5c 0%, #ffce06 100%) !important;
}
.login-inp p:last-child{
	display: inline-block;
	margin: 0 auto;
	line-height: 0.8rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 80%;
	color: #aeaeae;
	font-size: 0.33rem;
}
.login-bottom{
	margin-bottom: 5rem;
	position: fixed;
	width: 100%;
	height: 3.4rem;
}
.login-bottom .bottom-img{
	width: 40%;
	display: flex;
	justify-content: space-between;
	align-content: center;
	margin: 0 auto;
}
.login-bottom .bottom-img img{
	width: 1.1rem;
	height: 1.1rem;
}
.login-bottom p{
	margin: 0.7rem;
	margin-top: 0.6rem;
	color: #778899;
}
.login-bottom p button{
	border: none;
	background-color: white;
}
</style>
